package com.wgts.wgts.mvp.presenter.imp;

import com.wgts.wgts.mvp.model.IinvitationRecordFragmentModel;
import com.wgts.wgts.mvp.presenter.IinvitationRecordFragmentPresenter;
import com.wgts.wgts.mvp.view.IinvitationRecordFragmentView;
import com.wgts.wgts.netmodle.HttpResultSubscriber;
import com.wgts.wgts.netmodle.resp.RecordSpreadEntity;
import com.wgts.wgts.netmodle.resp.RecordSummaryEntity;

import java.util.List;

public class InvitationRecordFragmentPresenter implements IinvitationRecordFragmentPresenter {

    private IinvitationRecordFragmentModel model;

    private IinvitationRecordFragmentView view;

    public InvitationRecordFragmentPresenter(IinvitationRecordFragmentModel model, IinvitationRecordFragmentView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void initSpread(String type) {
        model.initSpread(type, new HttpResultSubscriber<List<RecordSpreadEntity>>() {
            @Override
            public void onSuccess(List<RecordSpreadEntity> recordSpreadEntity) {
                view.initSpreadResult(recordSpreadEntity);
            }

            @Override
            public void _onError(int status, String msg) {
                view.onError(status, msg);
            }
        });
    }

    @Override
    public void initSummary(String type) {
        model.initSummary(type, new HttpResultSubscriber<RecordSummaryEntity>() {
            @Override
            public void onSuccess(RecordSummaryEntity recordSummaryEntity) {
                view.initSummaryResult(recordSummaryEntity);
            }

            @Override
            public void _onError(int status, String msg) {
                view.onError(status, msg);
            }
        });
    }
}
